package com.example.book.mapper;

import com.example.book.model.BookInfo;
import com.example.book.model.PageRequest;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;

@Mapper
public interface BookMapper {

    @Insert("insert into book_info(book_name,author,count,price,publish,status) values(#{bookName},#{author},#{num},#{price},#{publishName},#{status})")
    void addBook(BookInfo bookInfo);

    @Select("SELECT * \n" +
            "FROM book_info \n" +
            "LIMIT #{offset}, #{pageSize}")
    ArrayList<BookInfo> getList(PageRequest pageRequest);

    @Select("SELECT COUNT(1) FROM book_info where status!=0")
    Integer count();

    @Update("update book_info set ")
    Integer update(BookInfo bookInfo);
}
